$(function() {
	var picker1 = $('#datetimepicker1').datetimepicker({
		format : 'yyyy-mm-dd',
		maxDate : new Date(2020, 5, 22),
		minDate : new Date(),
		startingDay : 1,
		weekStart : 1,
		startDate : new Date(2000, 5, 22),
		autoclose : true,
		minView : 2,
		todayBtn : true,
		todayHighlight : true,
		language : 'cn'
	// showMeridian : true,
	});
	var picker2 = $('#datetimepicker2').datetimepicker({
		format : 'yyyy-mm-dd',
		maxDate : new Date(2020, 5, 22),
		minDate : new Date(),
		startingDay : 1,
		weekStart : 1,
		startDate : new Date(2000, 5, 22),
		autoclose : true,
		minView : 2,
		todayBtn : true,
		todayHighlight : true,
		language : 'cn',
		initialDate : new Date(),
	});
	$('#datetimepicker1').datetimepicker().on('show', function(e) {
		$('#datetimepicker1').datetimepicker('update');
	});
	$('#datetimepicker2').datetimepicker().on('show', function(e) {
		$('#datetimepicker2').datetimepicker('update');
	});
	// 动态设置最小值
	$('#datetimepicker1').datetimepicker().on('changeDate', function(e) {
		var a = $("#datetimebegin").val();
		var b = $("#datetimeend").val();
		$('#datetimepicker2').datetimepicker('setStartDate', e.date);
		if (a > b) {
			$("#datetimeend").val(a);
		}
	});
	// 动态设置最大值
	$('#datetimepicker2').datetimepicker().on('changeDate', function(e) {
		var a = $("#datetimebegin").val();
		var b = $("#datetimeend").val();
		$('#datetimepicker1').datetimepicker('setEndDate', e.date);
		if (a > b || a == "") {
			$("#datetimebegin").val(b);
		}
	});
});